package com.cy.controller;

import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/provider")
public class RestProviderController {
    @DeleteMapping("{id}")
    public String doDeleteId(@PathVariable Long ...id){
        return Arrays.toString(id)+" is delete";
    }
    //添加操作
    @PostMapping
    public Map<String,Object> doCreate(@RequestBody Map<String,Object> map){
        //...后续将请求数据写入到数据库
        System.out.println("consumer.map = "+map);
        //定义响应结果
        String url = String.format("http://%s/provider/", "sca-provider");
        Map<String, Object> responseMap = new HashMap<>();
        responseMap.put("status",200);
        responseMap.put("message","insert ok");
        return responseMap;
    }
    //更新操作
    @PutMapping
    public Map<String,Object> doUpdate(@RequestBody Map<String,Object> map){
        //...后续将请求数据写入到数据库
        System.out.println("consumer.map = "+map);
        //定义响应结果
        String url = String.format("http://%s/provider/", "sca-provider");
        Map<String, Object> responseMap = new HashMap<>();
        responseMap.put("status",200);
        responseMap.put("message","update ok");
        return responseMap;
    }
}
